/**
 * 
 */
package org.blade.personal.framework.session.factory.concre;

import org.blade.personal.framework.jdbc.datasource.DataSource;
import org.blade.personal.framework.session.DslSession;
import org.blade.personal.framework.session.concre.StandardDslSession.StandardDslSession;
import org.blade.personal.framework.session.factory.Configuration;
import org.blade.personal.framework.session.factory.ConfigurationIsNullException;
import org.blade.personal.framework.session.factory.DslSessionFactory;

/**
 * @author Thinkpad
 *
 */
public class StandardDslSessionFactory implements DslSessionFactory {

	private Configuration cfg;
	
	/* (non-Javadoc)
	 * @see org.blade.personal.framework.session.factory.DslSessionFactory#buildDslSession()
	 */
	@Override
	public DslSession buildDslSession() {
		
		return buildDslSession(cfg);
	}

	/* (non-Javadoc)
	 * @see org.blade.personal.framework.session.factory.DslSessionFactory#buildDslSession(org.blade.personal.framework.session.factory.Configuration)
	 */
	@Override
	public DslSession buildDslSession(Configuration cfg) {
		
		if(null == cfg){
			throw new ConfigurationIsNullException(); 
		}
		DataSource ds = cfg.getDs();
		DslSession standardDslSession = new StandardDslSession(ds);
		
		return standardDslSession;
	}

}
